﻿@using zichan.Entity
@using zichan.Common;
@model IPagedList<AsseteClassify>
@{
    ViewBag.Title = "资产分类管理";
}
<style>
    #pagebar li {
        display: inline-block;
    }
</style>
@section Pagetitle{
    @AdminCommon.PageTitle("资产分类管理", "添加/删除/修改")
}
@*<link rel="stylesheet" type="text/css" href="/assets/global/plugins/select2/select2.css" />*@
@*<link href="/assets/global/css/plugins.css" rel="stylesheet" type="text/css" />*@
<div class="portlet">
    <div class="portlet-title">
        <div class="caption ">
            <i class="fa fa-table"></i>资产分类列表
        </div>
        <div class="actions pull-left leftMargin">
            @if (zichan.Common.PowerHelp.Check("AsseteClass", "create"))
            {
                <a href="@Url.Action("create", "AsseteClass")" class="btn default yellow-stripe">
                    <i class="fa fa-plus"></i>
                    <span class="hidden-480">添加资产分类</span>
                </a>
            }
        </div>
    </div>
    <div class="portlet-body">
        <div class="table-container">
            <div class="dataTables_wrapper dataTables_extended_wrapper no-footer">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="table-group-actions pull-left">
                            @using (Html.BeginForm("index", "AsseteClass", FormMethod.Get, new { @class = "form-inline" }))
                            {
                                <input type="hidden" name="pageSize" value="@ViewBag.pageSize" />
                                <div class="form-group">
                                    <input type="text" placeholder="资产分类" name="name" value="@ViewBag.name" class="form-control input-small input-sm" />
                                </div>
                                <div class="form-group">
                                    <input type="text" placeholder="资产标识" name="identity" value="@ViewBag.identity" class="form-control input-small input-sm" />
                                </div>
                                <button class="btn btn-sm yellow table-group-action-submit"><i class="fa fa-check"></i> 搜索</button>
                            }
                        </div>
                    </div>
                </div>
                <div class="row"><div class="col-md-6"><h5>资产分类总数:<span style="color:red;">@Model.TotalItemCount</span></h5></div><div class="col-md-6 "><span class="pull-right" style="color:red;">温馨提示：“资产标识”将作为资产编号的开头！</span></div></div>
                <div class="table-scrollable">
                    <table class="table  table-hover">
                        <thead>
                            <tr class="heading">
                                <th> 序号 </th>
                                <th>资产名称</th>
                                <th>资产标识</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (AsseteClassify r in Model)
                            {
                                <tr>
                                    <td>@r.SortId</td>
                                    <td>@r.Name</td>
                                    <td>
                                        @if (r.Id == 1)
                                        {
                                            @("品牌标识:" + r.Identity)<br>
                                            @("组装标识:" + r.SubIdentity)
                                        }
                                        else
                                        {
                                            @r.Identity
                                        }
                                    </td>
                                    <td>
                                        @if (PowerHelp.Check("AsseteClass", "edit"))
                                        {
                                            <a href="@Url.Action("edit", "AsseteClass", new {id=r.Id })" class="btn default btn-xs purple">
                                                <i class="fa fa-edit"></i> 编辑
                                            </a>
                                        }
                                        @if (PowerHelp.Check("AsseteClass", "AddFields"))
                                        {
                                            <a href="@Url.Action("FieldsIndex", "AsseteClass", new {assetClassId=r.Id })" class="btn default btn-xs purple">
                                                <i class="fa fa-edit"></i> 字段管理
                                            </a>
                                        }
                                        @if (PowerHelp.Check("AsseteClass", "delete") && r.UseCount == 0 && r.Id != 1)
                                        {
                                            @*<a href="@Url.Action("delete", "AsseteClass", new { id = r.Id })" class="btn default btn-xs black">*@
                                            <a class="btn default btn-xs black" href="javascript:if(confirm('确定要删除@(r.Name)?'))location='/AsseteClass/delete?id=@r.Id'">
                                                <i class="fa fa-trash-o"></i> 删除
                                            </a>
                                        }
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
                @if (PowerHelp.Check("Excel", "Exc"))
                {
                    <div class="row">
                        <div class="col-md-12">
                            <a href="@Url.Action("Exc", "Excel", new { name = ViewBag.name, identity = ViewBag.identity })" class="btn default green">
                                <i class="fa fa-table"></i>
                                <span class="hidden-480">Excel导出报表</span>
                            </a>
                        </div>
                    </div>
                }
                <div class="row">
                    <div class="col-md-12">
                        <div class="row">
                            <div class="col-sm-12 dataTables_paginate">
                                <div class="pull-right">
                                    <ul id="pagebar" style="display:inline-block;margin-right:10px;color:#3175AF;">
                                        <li>
                                            每页<select name="pageSize" id="pageSize" class="select2" style="width:50px;font-size:18px;">
                                                <option value="@ViewBag.pageSize">@ViewBag.pageSize</option>
                                                @foreach (var s in ViewBag.pageSizes)
                                                {
                                                    <option value="@s.Value">@s.Text</option>
                                                }
                                            </select>个
                                        </li>
                                        <li>第@(Model.PageNumber)/共@(Model.PageCount)页</li>
                                       @using (Html.BeginForm("index", "AsseteClass", FormMethod.Get,new { @style= "display: inline-block;" }))
                                       {<li style="display:none;"><input type="hidden" name="name" value="@ViewBag.name" /><input type="hidden" name="identity" value="@ViewBag.identity" />
                                            <input type="hidden" name="pageSize" value="@ViewBag.pageSize" />
                                        @Html.TextBox("pageCount",Model.PageCount)
                                        </li>
                                           <li>跳转至<input name="selectedPage" style="width:40px;font-size:18px;" value="@ViewBag.selectedPage" />页</li>
                                        <li><button type="submit">GO</button></li>}
                                    </ul>
                                    @if (Model.PageCount > 1)
                                    {<ul id="pagebar" class="pagination" style="margin:0px;float:right;">
                                        <li><a href="@Url.Action("Index", "asseteclass", new { name = ViewBag.name, identity = ViewBag.identity,pageSize=ViewBag.pageSize, page = 1 })">首页</a></li>
                                        <li>@Html.ActionLink("上一页", "Index", "asseteclass", new { name = ViewBag.name, identity = ViewBag.identity, pageSize = ViewBag.pageSize, page = Model.PageNumber - 1 }, null)</li>
                                        <li>@Html.ActionLink("下一页", "Index", "asseteclass", new { name = ViewBag.name, identity = ViewBag.identity, pageSize = ViewBag.pageSize, page = (Model.PageNumber + 1 < Model.PageCount ? Model.PageNumber + 1 : Model.PageCount) }, null)</li>
                                        <li>@Html.ActionLink("末页", "Index", "asseteclass", new { name = ViewBag.name, identity = ViewBag.identity, pageSize = ViewBag.pageSize, page = Model.PageCount }, null)</li>
                                    </ul>}
                                </div>

                            </div>
                        </div>


                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@*<script type="text/javascript" src="/assets/global/plugins/select2/select2.min.js"></script>*@

<script type="text/javascript">
    $(function () {
        $('#pageSize').on("change", function () {
            var name = $("input[name='name']").val();
            var identity = $("input[name='identity']").val();
            var size = $(this).val();
            location.href = "/asseteclass/Index?name=" + name + "&identity=" + identity + "&pageSize=" + size;
        });
    });
</script>
